/********************************************************************
*                                                                   *
* Microsoft Windows Sidebar Gadget for NNPORTAL.ORG                 *
* Released under the MIT license by Alexey Glukharev, 2011-2013.    *
*                                                                   *
********************************************************************/

//----------------------------------------
// Global variables
//---
var gadgetRegPath = "HKCU\\Software\\NNTTInformer";

//----------------------------------------
// Working with registry
//---
function writeSettings(key, value) {
    try {
        var wsh = new ActiveXObject("WScript.Shell");
        wsh.RegWrite(gadgetRegPath + "\\" + key, value, "REG_SZ");
    }
    catch (e) {
        var error = "NNTTInformer: Unable to write registry settings. Reason: " + e.description;
        System.Diagnostics.EventLog.writeEntry (error, 1);
        System.Debug.outputString(error);
    }
}

function readSettings(key) {
    var value = "";
    try {
        var wsh = new ActiveXObject("WScript.Shell");
        value = wsh.RegRead(gadgetRegPath + "\\" + key);
    }
    catch (e) {
        var error = "NNTTInformer: Unable to read registry settings. Reason: " + e.description;
        System.Diagnostics.EventLog.writeEntry (error, 1);
        System.Debug.outputString(error);
    }
    return value;
}